package com.lanou3g.ptp.api.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lanou3g.ptp.entity.User;
import com.lanou3g.ptp.sso.service.SsoService;
import com.lanou3g.utils.PtpResult;
import com.lanou3g.utils.PtpResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "用户登录接口")
@RestController
public class UserController {

    @Reference
    private SsoService ssoService;

    @ApiOperation("登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "登录信息"),
            @ApiImplicitParam(name = "password",value = "密码")
    })
    @PostMapping("/login")
    public PtpResult login(String name, String password) {
        String s = ssoService.ssoUser(name, password);
        if ("on".equals(s)) {
            return PtpResultUtils.error(499);
        } else {
            return PtpResultUtils.ok(s);
        }

    }
}
